//Module for handling the background, including procedural generation 
//and drawing of the starscape.

var planet = new Image();
planet.src = "images/Planet02.png";

//The array that holds the positions of all the stars in the starscape
var starArray = [];

//Defines how many stars should be in each structure.
var STAR_STRUCTURE_COUNT = 1200;

//Generates a nondescript field of stars scattered about haphazardly
function Background_generateStarfield(){
	starArray = [];
	for(var i = 0; i < STAR_STRUCTURE_COUNT; i++){
		starArray.push( [Math.random()*1600 - 800, Math.random()*1600  - 800, parseInt(Math.random()*2 + 1)] );
	}
}


function Background_draw(){
	ctx.fillStyle = "black";
	ctx.fillRect(player.pos.x-1000, player.pos.y-1000, 10000, 10000);
	ctx.fillStyle = "white";
	for(var i = 0; i < starArray.length; i++){
		var px = player.pos.x; var py = player.pos.y;
		ctx.beginPath();
		ctx.rect(px + starArray[i][0], py+starArray[i][1], starArray[i][2], starArray[i][2]);
		ctx.fill();
	}
	ctx.closePath();
	ctx.drawImage(planet, (-1)*PLANET_RADIUS, (-1)*PLANET_RADIUS);
}
